package com.dfec.book.exception;

/**
 * 自定义异常
 * @author tangrg
 * @email 1446232546@qq.com
 * @date 2025-06-19 14:42:38
 */
public class ServiceException extends RuntimeException {
    private static final long serialVersionUID = 1L;

    /**
     * 所属模块
     */
    private String module;


    /**
     * 错误信息
     */
    private String msg;

    /**
     * 错误编码
     */
    private int code = 500;

    /**
     * 错误码对应的参数
     */
    private Object[] args;


    public ServiceException(String module, String msg, int code, Object[] args) {
        this.module = module;
        this.msg = msg;
        this.code = code;
        this.args = args;
    }


    public ServiceException(String msg) {
        super(msg);
        this.msg = msg;
    }

    public ServiceException(String msg, Throwable e) {
        super(msg, e);
        this.msg = msg;
    }

    public ServiceException(String msg, int code) {
        super(msg);
        this.msg = msg;
        this.code = code;
    }

    public ServiceException(String msg, int code, Throwable e) {
        super(msg, e);
        this.msg = msg;
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Object[] getArgs() {
        return args;
    }

    public void setArgs(Object[] args) {
        this.args = args;
    }

}
